﻿using UnityEngine;
using System.Collections;
using FM_Mono;

[IgnoreGen]
public class RuntimeObjectCreator : MonoBehaviour
{
	public GameObject template;

	private GameObject _runtimeInst;
	// Use this for initialization
	void Start ()
	{
		if (template == null)
		{
			return;
		}
		_runtimeInst = GameObject.Instantiate<GameObject> (template);
		if (!_runtimeInst.activeSelf)
		{
			_runtimeInst.SetActive (true);
		}
		_runtimeInst.transform.SetParent (this.transform, false);
	}
	
	// Update is called once per frame
	void OnDestroy ()
	{
		if (_runtimeInst != null)
		{
			GameObject.Destroy (_runtimeInst);
			_runtimeInst = null;
		}
	}
}

